package com.sky.controller.user;

import com.sky.result.Result;
import com.sky.service.user.DishService;
import com.sky.vo.DishVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userDishController")
@RequestMapping("/user/dish")
@Slf4j
@RequiredArgsConstructor
public class DishController {
    public final DishService dishService;

    @GetMapping("/list")
    public Result<List<DishVO>> findAllByCategoryId(@RequestParam(required = false) Integer categoryId){
        List<DishVO> dishVOS = dishService.findAllByCategoryId(categoryId);
        log.info("查询结果：{}", dishVOS);
        return Result.success(dishVOS);
    }
}
